package com.ruoyi.jproom.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.jproom.entity.DemandInfo;
import com.ruoyi.jproom.service.DemandHousingService;
import com.ruoyi.jproom.utils.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author zeo
 * @explain 我要租房 我要买房 控制层
 * @date 2020/8/6 15:32
 */
@Controller
@RequestMapping("/demandHousing")
public class DemandHousingController extends BaseController {

    @Autowired
    DemandHousingService demandHousingService;

    /**
     * 客户端我要买房委托
     *
     * @param demandInfo
     * @return
     */
    @RequestMapping("/insertMeBuyHousingEntrust")
    @ResponseBody
    public BaseResult insertMeBuyHousingEntrust(DemandInfo demandInfo) {
        return demandHousingService.insertMeBuyHousingEntrust(demandInfo);
    }

    /**
     * 客户端我要租房委托
     *
     * @param demandInfo
     * @return
     */
    @RequestMapping("/insertMeRentHousingEntrust")
    @ResponseBody
    public BaseResult insertMeRentHousingEntrust(DemandInfo demandInfo) {
        return demandHousingService.insertMeRentHousingEntrust(demandInfo);
    }



    /**
     * 服务端我要买房委托管理页面跳转
     *
     * @return
     */
    @GetMapping("/MeBuyHousingEntrustManage")
    public String MeBuyHousingEntrustManage() {
        return "demand/meBuyHousingEntrustManage";
    }

    /**
     * 服务端我要租房委托管理页面跳转
     *
     * @return
     */
    @GetMapping("/MeRentHousingEntrustManage")
    public String MeRentHousingEntrustManage() {
        return "demand/meRentHousingEntrustManage";
    }

    @RequestMapping("/findMeBuyHousingEntrustList")
    @ResponseBody
    public TableDataInfo findMeBuyHousingEntrustList(DemandInfo demandInfo) {
        startPage();
        return getDataTable(demandHousingService.findMeBuyHousingEntrustList(demandInfo));
    }

    @RequestMapping("/toVoid")
    @ResponseBody
    public AjaxResult toVoid(String demandId){
        return toAjax(demandHousingService.toVoid(demandId));
    }



    @RequestMapping("/findMeRentHousingEntrustList")
    @ResponseBody
    public TableDataInfo findMeRentHousingEntrustList(DemandInfo demandInfo) {
        startPage();
        return getDataTable(demandHousingService.findMeRentHousingEntrustList(demandInfo));
    }


    @RequestMapping("/changeIsHandle")
    @ResponseBody
    public AjaxResult changeIsHandle(String demandId,String isHandle){
        return toAjax(demandHousingService.changeIsHandle(demandId,isHandle));
    }
}
